require 'sqlite3'
require_relative 

class Database
  
  def initialize
    unless(File.exists('code.db')
      db = SQLite3::Database.new("code.db")
  
      db.execute('CREATE TABLE unit_test_file (id INTEGER PRIMARY KEY, filename TEXT);
      CREATE TABLE features (id INTEGER PRIMARY KEY, unit_test_file_id INTEGER);
      CREATE TABLE fulcrums (id INTEGER PRIMARY KEY, assertion TEXT, sentiment TEXT, feature_id NUMERIC);
      CREATE TABLE tokens (id INTEGER PRIMARY KEY, importance NUMERIC, type TEXT, value TEXT, feature_id NUMERIC);')
    end
  end
  
  def save_features(features)
    db.prepare('INSERT INTO unit_test_file (filename) VALUES(:filename)') do |stmt|
      features.each do |feature|
        stmt.execute filename: feature.unit_test_file
      end
    end
    
  end
  
end

